package com.example.demo.service;

import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.example.demo.entity.ImgDetail;
import com.example.demo.mapper.ImgDetailMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;

@Service
public class ImgDetailService {
    @Autowired
    ImgDetailMapper imgDetailMapper;

    public List<ImgDetail> insertImg(ImgDetail imgDetail){
        List<ImgDetail> chachong = imgDetailMapper.chachong(imgDetail.getImgid(), imgDetail.getUserid());
        if( CollectionUtils.isEmpty(chachong)==false) {
            List<ImgDetail> detail = new ArrayList<>();
            detail.add(new ImgDetail());
            return  detail;
        }
        if( CollectionUtils.isEmpty(chachong)==true){
            imgDetailMapper.insertDetailImg(imgDetail.getImgid(),imgDetail.getUserid());
          return imgDetailMapper.chachong(imgDetail.getImgid(),imgDetail.getUserid());
        }
       return  new ArrayList<>();
    }

    public List<ImgDetail> getuid(String userid){
     return   imgDetailMapper.gtuid(userid);
    }
}
